home *** CD-ROM | disk | FTP | other *** search
Text File | 1992-06-19 | 2.8 KB | 168 lines | [TEXT/MPS ] |
- #define SystemSevenOrLater 1
-
- #include <errors.h>
-
- #include "aevent.h"
- #include "templock.h"
-
- aevent::aevent( AEEventClass theclass,
- AEEventID id,
- const AEAddressDesc& target )
- {
- error= AECreateAppleEvent( theclass,
- id,
- &target,
- kAutoGenerateReturnID,
- kAnyTransactionID,
- this );
- mode= kAENoReply | kAECanInteract | kAECanSwitchLayer;
- priority= kAENormalPriority;
- timeout= kAEDefaultTimeout;
- idler= 0;
- filter= 0;
- }
-
- OSErr aevent::send()
- {
- if (iswrong())
- return whatiswrong();
-
- return AESend( this,
- &reply,
- mode,
- priority,
- timeout,
- idler,
- filter );
- }
-
- void aevent::putparam( AEKeyword key,
- DescType type,
- void *data,
- uint32 size )
- {
- if (iswrong())
- return;
-
- error= AEPutParamPtr( this,
- key,
- type,
- (Ptr)data,
- size );
- }
-
- void aevent::putparam( AEKeyword key,
- DescType type,
- Handle h )
- {
- if (iswrong())
- return;
-
- templock lock(h);
-
- putparam( key, type, *h, GetHandleSize(h) );
- }
-
- void aevent::putparam( AEKeyword key, const AEDesc& param )
- {
- if (iswrong())
- return;
-
- error= AEPutParamDesc( this, key, ¶m );
- }
-
- void aevent::putattribute( AEKeyword key,
- DescType type,
- void *data,
- uint32 size )
- {
- if (iswrong())
- return;
-
- error= AEPutAttributePtr( this,
- key,
- type,
- (Ptr)data,
- size );
- }
-
- void aevent::putattribute( AEKeyword key,
- DescType type,
- Handle h )
- {
- if (iswrong())
- return;
-
- templock lock(h);
-
- putattribute( key, type, *h, GetHandleSize(h) );
- }
-
- void aevent::putattribute( AEKeyword key, const AEDesc& param )
- {
- if (iswrong())
- return;
-
- error= AEPutAttributeDesc( this, key, ¶m );
- }
-
- OSErr aevent::getparam( AEKeyword key,
- DescType desired,
- DescType& realtype,
- void *data,
- uint32 maxsize,
- uint32& truesize )
- {
- if (iswrong())
- return whatiswrong();
-
- return AEGetParamPtr( this,
- key,
- desired,
- &realtype,
- (Ptr)data,
- maxsize,
- (Size *)&truesize );
- }
-
- OSErr aevent::getparam( AEKeyword key,
- DescType desired,
- DescType& realtype,
- Handle& result )
- {
- uint32 size;
- OSErr error= getparam( key,
- desired,
- realtype,
- 0,
- 0,
- size );
- if ( error != noErr )
- return error;
-
- result= NewHandle(size);
- if ( result==0 )
- return mFulErr;
-
- templock lock(result);
- return getparam( key,
- desired,
- realtype,
- *result,
- size,
- size );
- }
-
- OSErr aevent::getparam( AEKeyword key,
- DescType desired,
- AEDesc& result )
- {
- if (iswrong())
- return whatiswrong();
-
- return AEGetParamDesc( this,
- key,
- desired,
- &result );
- }
-